/**
 * 初始化页面
 */
function initPage() {
    win.crebtn('addWindow_btnCancel', '关闭', win.close);
    win.crebtn('addWindow_btnSave', '保存', addModuleAction);
    document.getElementById("MODULE_DM_SJ").value = myTools.getQueryString("MODULE_DM_SJ");
    getModuleSJOrder();
    Validator.validate(document.getElementById(("addModuleActionForm")), 3);
}
/**
 *保存模块操作
 */
function addModuleAction() {
    if (!Validator.validate(document.getElementById(("addModuleActionForm")), 4))
        return false;

    var orders = document.getElementById("ORDERS").value;
    var ordersall_sj = document.getElementById("ORDERSALL_SJ").value;
    var ordersall = ordersall_sj + "" + LPad(orders, '0', 3);
    document.getElementById("ORDERSALL").value = ordersall;
    var json = {
        url:contextPath +"/server/sys/insertModule.do",
        msg:"数据保存中.....",
        form:"addModuleActionForm",
        params:{
            "SQLID":"module.insertModule"
        },
        callback:[addModuleActionCallBack]
    };
    AjaxTools.ajax(json);
}
function addModuleActionCallBack(data) {
    var code = data.code;
    if (code == "0") {
        alert(data.msg);
        window.parent.parent.getModuleAction();
        win.close('addWindow');
    } else {
        alert(data.msg);
    }

}
/**
 取上级模块的全局顺序
 */
function getModuleSJOrder() {
    var json = {
        url:contextPath +"/server/base/selectByID.do",
        msg:"数据加载中.....",
        params:{
            "MODULE_DM": myTools.getQueryString("MODULE_DM_SJ"),
            "SQLID":"module.selectModuleBY_ID"
        },
        callback:[getModuleSJOrderCallBack]
    };
    AjaxTools.ajax(json);
}
function getModuleSJOrderCallBack(json) {
    document.getElementById("ORDERSALL_SJ").value = json.data.ORDERSALL;
}
